home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SUNRPC / CLNT.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  146 lines

  1. /*
  2.  *  linux/include/linux/sunrpc/clnt.h
  3.  *
  4.  *  Declarations for the high-level RPC client interface
  5.  *
  6.  *  Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
  7.  */
  8.  
  9. #ifndef _LINUX_SUNRPC_CLNT_H
  10. #define _LINUX_SUNRPC_CLNT_H
  11.  
  12. #include <linux/sunrpc/msg_prot.h>
  13. #include <linux/sunrpc/sched.h>
  14. #include <linux/sunrpc/xprt.h>
  15. #include <linux/sunrpc/auth.h>
  16. #include <linux/sunrpc/stats.h>
  17. #include <linux/sunrpc/xdr.h>
  18.  
  19. /*
  20.  * This defines an RPC port mapping
  21.  */
  22. struct rpc_portmap {
  23.     __u32            pm_prog;
  24.     __u32            pm_vers;
  25.     __u32            pm_prot;
  26.     __u16            pm_port;
  27. };
  28.  
  29. /*
  30.  * The high-level client handle
  31.  */
  32. struct rpc_clnt {
  33.     unsigned int        cl_users;    /* number of references */
  34.     struct rpc_xprt *    cl_xprt;    /* transport */
  35.     struct rpc_procinfo *    cl_procinfo;    /* procedure info */
  36.     u32            cl_maxproc;    /* max procedure number */
  37.  
  38.     char *            cl_server;    /* server machine name */
  39.     char *            cl_protname;    /* protocol name */
  40.     struct rpc_auth *    cl_auth;    /* authenticator */
  41.     struct rpc_stat *    cl_stats;    /* statistics */
  42.  
  43.     unsigned int        cl_softrtry : 1,/* soft timeouts */
  44.                 cl_intr     : 1,/* interruptible */
  45.                 cl_chatty   : 1,/* be verbose */
  46.                 cl_autobind : 1,/* use getport() */
  47.                 cl_binding  : 1,/* doing a getport() */
  48.                 cl_oneshot  : 1,/* dispose after use */
  49.                 cl_dead     : 1;/* abandoned */
  50.     unsigned int        cl_flags;    /* misc client flags */
  51.     unsigned long        cl_hardmax;    /* max hard timeout */
  52.  
  53.     struct rpc_portmap    cl_pmap;    /* port mapping */
  54.     struct rpc_wait_queue    cl_bindwait;    /* waiting on getport() */
  55.  
  56.     int            cl_nodelen;    /* nodename length */
  57.     char             cl_nodename[UNX_MAXNODENAME];
  58. };
  59. #define cl_timeout        cl_xprt->timeout
  60. #define cl_prog            cl_pmap.pm_prog
  61. #define cl_vers            cl_pmap.pm_vers
  62. #define cl_port            cl_pmap.pm_port
  63. #define cl_prot            cl_pmap.pm_prot
  64.  
  65. /*
  66.  * General RPC program info
  67.  */
  68. #define RPC_MAXVERSION        4
  69. struct rpc_program {
  70.     char *            name;        /* protocol name */
  71.     u32            number;        /* program number */
  72.     unsigned int        nrvers;        /* number of versions */
  73.     struct rpc_version **    version;    /* version array */
  74.     struct rpc_stat *    stats;        /* statistics */
  75. };
  76.  
  77. struct rpc_version {
  78.     u32            number;        /* version number */
  79.     unsigned int        nrprocs;    /* number of procs */
  80.     struct rpc_procinfo *    procs;        /* procedure array */
  81. };
  82.  
  83. /*
  84.  * Procedure information
  85.  */
  86. struct rpc_procinfo {
  87.     char *            p_procname;    /* procedure name */
  88.     kxdrproc_t        p_encode;    /* XDR encode function */
  89.     kxdrproc_t        p_decode;    /* XDR decode function */
  90.     unsigned int        p_bufsiz;    /* req. buffer size */
  91.     unsigned int        p_count;    /* call count */
  92. };
  93.  
  94. #define rpcproc_bufsiz(clnt, proc)    ((clnt)->cl_procinfo[proc].p_bufsiz)
  95. #define rpcproc_encode(clnt, proc)    ((clnt)->cl_procinfo[proc].p_encode)
  96. #define rpcproc_decode(clnt, proc)    ((clnt)->cl_procinfo[proc].p_decode)
  97. #define rpcproc_name(clnt, proc)    ((clnt)->cl_procinfo[proc].p_procname)
  98. #define rpcproc_count(clnt, proc)    ((clnt)->cl_procinfo[proc].p_count)
  99.  
  100. #define RPC_CONGESTED(clnt)    (RPCXPRT_CONGESTED((clnt)->cl_xprt))
  101. #define RPC_PEERADDR(clnt)    (&(clnt)->cl_xprt->addr)
  102.  
  103. #ifdef __KERNEL__
  104.  
  105. struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
  106.                 struct rpc_program *info,
  107.                 u32 version, int authflavor);
  108. int        rpc_shutdown_client(struct rpc_clnt *);
  109. int        rpc_destroy_client(struct rpc_clnt *);
  110. void        rpc_release_client(struct rpc_clnt *);
  111. void        rpc_getport(struct rpc_task *, struct rpc_clnt *);
  112. int        rpc_register(u32, u32, int, unsigned short, int *);
  113.  
  114. int        rpc_call(struct rpc_clnt *clnt, u32 proc,
  115.                 void *argp, void *resp, int flags);
  116. int        rpc_call_async(struct rpc_task *task, u32 proc,
  117.                 void *argp, void *resp, int flags);
  118. void        rpc_call_setup(struct rpc_task *task, u32 proc,
  119.                 void *argp, void *resp, int flags);
  120. int        rpc_do_call(struct rpc_clnt *clnt, u32 proc,
  121.                 void *argp, void *resp, int flags,
  122.                 rpc_action callback, void *clntdata);
  123. void        rpc_restart_call(struct rpc_task *);
  124. void        rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
  125. void        rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
  126.  
  127. #define rpc_call(clnt, proc, argp, resp, flags)    \
  128.         rpc_do_call(clnt, proc, argp, resp, flags, NULL, NULL)
  129.  
  130. extern __inline__ void
  131. rpc_set_timeout(struct rpc_clnt *clnt, unsigned int retr, unsigned long incr)
  132. {
  133.     xprt_set_timeout(&clnt->cl_timeout, retr, incr);
  134. }
  135.  
  136. extern void rpciod_tcp_dispatcher(void);
  137. extern void rpciod_wake_up(void);
  138.  
  139. /*
  140.  * Helper function for NFSroot support
  141.  */
  142. int        rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
  143.  
  144. #endif /* __KERNEL__ */
  145. #endif /* _LINUX_SUNRPC_CLNT_H */
  146.